package cn.neusoft.edu.his.demo.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import cn.neusoft.edu.his.demo.po.User;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

@Mapper
public interface UserMapper extends BaseMapper<User>{
	
	@Select("select u.* from user u where u.user_name=#{userName} and password=#{password} and user_role=#{userRole}")
	User checkLogin(User user);

	@Select("select u.* from user u where u.user_name=#{userName} and password=#{password}")
	User checkLogin2(User user);
	
	@Select("select u.* from user u where u.user_name=#{userName} or u.telephone=#{telephone}")
	User checkUserName(User user);
	
	@Select("select u.*,t.* from  user u,user_role t where u.user_role=t.role_id")//select u.* from user u
	List<User> getUsers();
	
	@Update("update user set user_name=#{userName},telephone=#{telephone},real_name=#{realName},user_role=#{userRole} where user_id=#{userId}")
	public int  updateUser(User user);
	
	@Update("update user set password='123456' where user_id=#{userId}")
	public int  updatePassword(User user);

}
